import { IndexService } from '../services/IndexService';
import { Get, NotFoundError, JsonController, Ctx, UseBefore } from 'routing-controllers'
import { Inject, Service } from 'typedi';
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
import { Context } from 'koa';

@Service()
@JsonController('/index')
export class IndexController {

  @Inject()
  private indexService!: IndexService;

  @OpenAPI({ summary: 'Index Controller' })
  @Get('/')
  public async index(@Ctx() ctx: Context): Promise<any> {
    console.log(ctx);
    const indexRes = await this.indexService.index();
    return indexRes;
  }

  @Get('/error')
  public errors(): any {
    throw new NotFoundError('Page not found')
  }

}
